package com.testin.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.testin.model.ModelPage;
import com.testin.utils.MailConfig;
import com.testin.utils.WriteMailModel;


public class ForwardServlet extends BaseServlet {
	private static final long serialVersionUID = 7422910046866929397L;

	private MailConfig mailConfig;	


	/**
	 * 跳转页面
	 */
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		WriteMailModel writeMailModel = new WriteMailModel();
		List<ModelPage> modelPageList =null;
	    //request.setAttribute(Constants.HOT_BOOKS_KEY, books);
		//this.sendMail("lizhongbin@360buy.com", "您好,测试一下",accountList);
		try{
		
		//writeMailModel.sendMail("lizhongbin@360buy.com", "您好,测试一下",modelPageList);
		}catch(Exception e){
			e.printStackTrace();
		}

         forward(request, response, "/testin/project.jsp");
	}
	
	
/*	*//**
	 * 发送邮件
	 * @throws MessagingException 
	 *//*
	public void sendMail(String mailStr, String returnStr,List<Account> accountList) throws MessagingException {

		Properties   props   =   System.getProperties(); 
		Session   session   =   Session.getDefaultInstance(props,   null); 
		StringBuffer   htmlText = new StringBuffer();
		
		htmlText.append("<body>");
		htmlText.append("<table border=\"1\">");
		htmlText.append("<tr>");
		htmlText.append("<td>序号</td><td>项目</td><td>内容</td><td>备注</td>");
		htmlText.append("</tr>");
		
		int i=1;
		for(Account account: accountList){
		htmlText.append("<tr>");
		htmlText.append("<td>"+i+"</td><td>"+account.getUsername()+"</td><td>"+account.getCmp_name()+"</td><td>"+account.getCmp_address()+"</td>");
		htmlText.append("</tr>");
		}		
		htmlText.append("</table>");
		htmlText.append("</body>");
		

		Message  message =new MimeMessage(session);
		message.setContent(htmlText,"text/html"); 
		SendMultiPartEmail sendMultiPartEmail = new SendMultiPartEmail("mail.360buy.com", "lizhongbin@360buy.com","lzbhl121429@bbb");
		sendMultiPartEmail.setFrom("lizhongbin@360buy.com");
		sendMultiPartEmail.addSendTo(mailStr);
		sendMultiPartEmail.setSubject("测试系统(来自：李忠斌)");
		// 获取新邮件内容
		sendMultiPartEmail.setMessageBody(htmlText.toString());
		try{
		sendMultiPartEmail.send();
		}catch(Exception e){
			e.printStackTrace();
		}
	}
*/
	public MailConfig getMailConfig() {
		return mailConfig;
	}

	public void setMailConfig(MailConfig mailConfig) {
		this.mailConfig = mailConfig;
	}
	
	

}
